#ifndef DATABASE_EXCEPTIONS_BASE_H
#define DATABASE_EXCEPTIONS_BASE_H
/*
*/

#include <cstdio>
#include <cstdint>
#include <string>


namespace Database
{

const unsigned int E_FIELD_VALUE		= 0x00000001;
const unsigned int E_INTERNAL_ERROR		= 0xF0000000;
const unsigned int E_RUNTIME_ERROR		= 0xF0000001;


// EDatabase is a convenience base class.  It should never be throw()n, hence the protected ctor.
class EDatabase
{
protected:
	EDatabase(const unsigned int code, const char * const message);

public:
	virtual const char * what() const throw();
	virtual ~EDatabase() throw();

protected:
	const char * format(const char *msg);

	unsigned int code_;
	char message_[256];
};


class EInternal : public EDatabase
{
public:
	EInternal() : EDatabase(E_INTERNAL_ERROR, "Internal error") { };
	EInternal(const unsigned int code, const char * const message) : EDatabase(code, message) { };
};


class ERuntime : public EDatabase
{
public:
	ERuntime() : EDatabase(E_RUNTIME_ERROR, "Runtime error") { };
	ERuntime(const unsigned int code, const char * const message) : EDatabase(code, message) { };
};


}	// namespace Database

#endif

